const db = wx.cloud.database()
// pages/end1/end1.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    bottom: [{
      id: 0,
      text: "首页",
      selectedIcon: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/icon/6.0.0.png?sign=8efcdca8770c182531fd1d0a5b98bee7&t=1621066787",
      selectIcon: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/icon/6.0.1.png?sign=4b58233a9a18aed2b79064b59005387e&t=1621066799",
    }, {
      id: 1,
      text: "活动",
      selectIcon: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/icon/7.0.0.png?sign=012969fbfc15e20d6ae5c4a6c9d67f5a&t=1621066822",
      selectedIcon: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/icon/7.0.1.png?sign=837e43574ead133a890d0afe82a79415&t=1621066837",
    }, {
      id: 2,
      text: "收藏",
      selectedIcon: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/icon/8.0.0.png?sign=8a80489dff605f44d9507571a1512f7d&t=1621066859",
      selectIcon: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/icon/8.0.1.png?sign=60ca372b800fe19715747f7a84800229&t=1621069677",
    }, {
      id: 3,
      text: "我的",
      selectIcon: "https://646f-dongyingyin-3khfy-1300530180.tcb.qcloud.la/icon/9.0.1.png?sign=ded7f69596df7b109d7bc7516da3ac2c&t=1621066877",
      selectedIcon: "",
    }],
    "collection_data":[],
    card_id: "0",
    showView1: true,
    showView2: true,
  },

  bottomJump: function (e) {
    console.log(e.currentTarget.dataset.bottomitemdata)
    if ("首页" === e.currentTarget.dataset.bottomitemdata) {
      wx.navigateTo({
        url: '../../pages/end/end'
      })

    } else if ("活动" === e.currentTarget.dataset.bottomitemdata) {
      wx.navigateTo({
        url: '../../pages/end1/end1' 
      })
    } else if ("收藏" === e.currentTarget.dataset.bottomitemdata) {
      wx.navigateTo({
        url: '../../pages/end2/end2'
      })
    } else if ("我的" === e.currentTarget.dataset.bottomitemdata) {
      wx.navigateTo({
        url: '../../pages/end3/end3'
      })
    }
  },

  onChangeShowState1: function () {
    var that = this;
    that.setData({
      showView1: (!that.data.showView1)
    })
  },

  cardJump: function (e) {
    // console.log(e)
    getApp().globalData.collection = e.currentTarget.dataset.collection
    wx.navigateTo({
       url: '../../pages/activity1/activity1'
    })
  },


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    showView1: (options.showView1 == "true" ? true : false)
    db.collection("collection_data").get().then(res=>{
      console.log("成功1",res)
      var collection_data=[];
      var _openid= getApp().globalData.openid;
      for(let i = 0;i < res.data.length;i++){
        console.log("空",res.data[i]._openid)
        if (res.data[i]._openid == _openid){
          collection_data.push(res.data[i])
        }
      }
      console.log("成功",collection_data)
      this.setData({
        collection_data,
      })
    })
   
  }
})